app.controller('imgTabCtrl', ['$rootScope', '$scope', 'httpLoad', '$modal', '$stateParams', '$state', function ($rootScope, $scope, httpLoad, $modal, $stateParams, $state) {
    $rootScope.moduleTitle = '容器管理 > 镜像';
    $rootScope.link = '/statics/css/tpl-card.css';
    $scope.isBack = false;
    var id = $stateParams.id;
    var flag = $stateParams.flag;
    if(flag==null){
        $scope.isBack = false;
    }else{
        $scope.isBack = true;
    }
    var flag_tab = sessionStorage.getItem('imgtabLocation')||1;
    switch (flag_tab/1){
        case 1:
            $scope.isImg = true;
            break;
        case 2:
            $scope.isShop = true;
            break;
    }
    sessionStorage.setItem('imgtabLocation','1');
    $scope.goBack = function(){
        if(flag==0){
              $state.go('app.resources.warehouse');
        }
    };
}]);
app.controller('imgCtrl', ['$rootScope', '$scope', 'httpLoad', '$modal', '$stateParams', '$state',function ($rootScope, $scope, httpLoad, $modal, $stateParams, $state) {
    $scope.param = {
        page: 1,
        rows: 10
    };
    //获取
    $scope.getData = function (page) {
        $scope.showDetail = false;
        $scope.param.page = page || $scope.param.page;
        $scope.param.imageName = $scope.searchByname;
        // $scope.param.warehouseId = $stateParams.id;
        httpLoad.loadData({
            url: '/deployer/getAllImageInfo.do',
            data: $scope.param,
            method:"GET",
            noParam: true,
            success: function (data) {
                if (data.rows&&data.rows.length!=0) {
                    $scope.imgList = data.rows;
                    $scope.totalCount = data.total;
                }else{
                    $scope.isImageData = true;
                }
            }
        });
    };

    //app
    $scope.showApp = function(item){  //打开模态
        var modalInstance = $modal.open({
            templateUrl : '/statics/tpl/containerManger/img/appList.html',  //指向上面创建的视图
            controller : 'showAppModalCtrl',// 初始化模态范围
            resolve : {
                itemData: function() {
                    return item;
                }
            }
        });
        modalInstance.result.then(function(data){
            angular.extend(item,data);
        },function(){});
    };

    //con
    $scope.showCon = function(item){  //打开模态
        var modalInstance = $modal.open({
            templateUrl : '/statics/tpl/containerManger/img/conList.html',  //指向上面创建的视图
            controller : 'showConModalCtrl',// 初始化模态范围
            resolve : {
                itemData: function() {
                    return item;
                }
            }
        });
        modalInstance.result.then(function(data){
            angular.extend(item,data);
        },function(){});
    };

    //跳转详情页
    $scope.detail = function(item){
        $state.go('app.containerManger.imgDetail',{id:item.id,name:item.name});
    };
    $scope.goApp = function(id){  //打开模态
        $state.go('app.application.developDetail',{id:id});
    };
}])
//app
angular.module('app').controller('showAppModalCtrl',['$state','$scope','$modalInstance','LANGUAGE','httpLoad','itemData',
    function($state,$scope,$modalInstance,LANGUAGE,httpLoad,itemData){
        $scope.appNameList = itemData;
        $scope.cancel = function(){
            $modalInstance.dismiss('cancel'); // 退出
        };
        $scope.detailApp = function(item){
            $modalInstance.dismiss('cancel');
            $state.go('app.application.developDetail',{id:item.appId,appName:item.appName.substring(0,item.appName.indexOf("-")),appCoreRename:item.appName,flag:1});
        };
    }]);
//con
angular.module('app').controller('showConModalCtrl',['$state','$scope','$state','$modalInstance','LANGUAGE','httpLoad','itemData',
    function($state,$scope,$state,$modalInstance,LANGUAGE,httpLoad,itemData){
        $scope.conNameList = itemData;
        $scope.cancel = function(){
            $modalInstance.dismiss('cancel'); // 退出
        };
        //跳转详情页
        $scope.detailCon = function(item){
            $modalInstance.dismiss('cancel');
            $state.go('app.containerManger.containerDetail',{conName:item,flag:1});
        };
    }]);